package com.medi.web.controller.business;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.medi.common.annotation.Log;
import com.medi.common.core.controller.BaseController;
import com.medi.common.core.domain.AjaxResult;
import com.medi.common.enums.BusinessType;
import com.medi.business.domain.DataInterface;
import com.medi.business.service.IDataInterfaceService;
import com.medi.common.core.page.TableDataInfo;

/**
 * 需要数据权限控制接口Controller
 * 
 * @author medi
 * @date 2024-09-13
 */
@Api(tags = "后台管理-数据权限接口管理")
@RestController
@RequestMapping("/business/interface")
public class DataInterfaceController extends BaseController
{
    @Autowired
    private IDataInterfaceService dataInterfaceService;

    /**
     * 查询需要数据权限控制接口列表
     */
    @ApiOperation("查询需要数据权限控制接口列表翻页")
    @GetMapping("/list")
    public TableDataInfo list(DataInterface dataInterface)
    {
        startPage();
        List<DataInterface> list = dataInterfaceService.selectDataInterfaceList(dataInterface);
        return getDataTable(list);
    }

    /**
     * 获取需要数据权限控制接口详细信息
     */
    @ApiOperation("获取需要数据权限控制接口详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(dataInterfaceService.selectDataInterfaceById(id));
    }

    /**
     * 查询需要数据权限控制接口列表
     */
    @ApiOperation("查询需要数据权限控制接口列表")
    @GetMapping(value = "/getAll")
    public AjaxResult getAll()
    {
        return success(dataInterfaceService.selectDataInterfaceList(new DataInterface()));
    }

    /**
     * 新增需要数据权限控制接口
     */
    @ApiOperation("添加控制接口列表")
    @Log(title = "添加控制接口列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataInterface dataInterface)
    {
        return toAjax(dataInterfaceService.insertDataInterface(dataInterface));
    }

    /**
     * 修改需要数据权限控制接口
     */
    @ApiOperation("修改需要数据权限控制接口")
    @Log(title = "修改需要数据权限控制接口", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataInterface dataInterface)
    {
        return toAjax(dataInterfaceService.updateDataInterface(dataInterface));
    }

    /**
     * 删除需要数据权限控制接口
     */
    @PreAuthorize("@ss.hasPermi('business:interface:remove')")
    @Log(title = "需要数据权限控制接口", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(dataInterfaceService.deleteDataInterfaceByIds(ids));
    }
}
